﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.FxCop.Sdk;

namespace SinacorRules
{
    public sealed class Rule_DontInheritSystemEnum : BaseAddIn.Rules.BaseRuleFXCop
    {
        #region Campos

        private Type _tipoENum;

        #endregion

        #region Constructor

        public Rule_DontInheritSystemEnum()
            : base("DontInheritSystemEnum", "SinacorRules.SinacorRules", typeof(Rule_DontInheritSystemEnum).Assembly)
        {
            _tipoENum = typeof(System.Enum);
        }

        #endregion

        #region Public Override Methods

        public sealed override ProblemCollection Check(string namespaceName, TypeNodeCollection types)
        {
            List<ClassNode> listaClasses = new List<ClassNode>(types.OfType<ClassNode>());

            foreach (ClassNode classe in listaClasses)
            {
                if (Common.Rotinas.CheckClassInheritance(classe, _tipoENum))
                {
                    AddError(classe, "DontInheritSystemEnum", classe.Name.Name, classe.Namespace.Name);
                }
            }

            return base.Problems;
        }

        #endregion
    }
}
